const debounce = {
  mounted(el, binding) {
    // 至少需要回调函数以及监听事件类型
    el.handler = function () {
      if (!el.disabled) {
        el.disabled = true;
        el.style.opacity = '0.5';
        el.style.cursor = 'not-allowed';
        setTimeout(() => {
          el.disabled = false;
          el.style.opacity = '1';
          el.style.cursor = '';
        }, binding.value || 2000);
      }
    };

    el.addEventListener('click', el.handler);
  },
};

export default debounce;
